package com.buildings.activity.table;

import android.annotation.SuppressLint;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;

import com.buildings.R;
import com.buildings.api.Api;
import com.buildings.api.Constant;
import com.buildings.base.BaseActivity;
import com.buildings.base.BaseApplication;
import com.buildings.bean.GeologicalSvyPlanningLineDbEntity;
import com.buildings.bean.LoginBean;
import com.buildings.bean.SamplePointEntity;
import com.buildings.bean.VolcanicSvyPointDbEntity;
import com.buildings.bean.VolcanicSvyPointEntity;
import com.buildings.http.BaseCallBack;
import com.buildings.http.JsonBuilder;
import com.buildings.http.MyHttpClient;
import com.buildings.util.CustomToast;
import com.buildings.util.DialogUtils;
import com.buildings.util.FileUtil;
import com.buildings.util.HYDialogUtils;
import com.buildings.util.HYImageUtils;
import com.buildings.util.PhotoRecycleBuild;
import com.buildings.util.SPUtil;
import com.buildings.util.StringUtil;
import com.buildings.util.TabTitleBuilder;
import com.buildings.view.ShowBottomDialog;
import com.zr.earthquate.db.greendao.DaoSession;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;

//火山调查观测点-点
public class VolcanicSvyPointActivity extends BaseActivity {
    @BindView(R.id.ll_tab_title)
    LinearLayout llTabTitle;
    @BindView(R.id.rv_pics)
    RecyclerView rvPics;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_right_text)
    TextView tvRightText;

    @BindView(R.id.et_id)
    EditText etId;
    @BindView(R.id.et_fieldid)
    EditText etFieldid;
    @BindView(R.id.et_locationname)
    EditText etLocationname;
    @BindView(R.id.et_svydate)
    TextView etSvydate;
    @BindView(R.id.et_purpose)
    EditText etPurpose;
    @BindView(R.id.et_spcommentInfo)
    EditText etSpcommentInfo;
    @BindView(R.id.et_elevation)
    EditText etElevation;
    @BindView(R.id.et_svymethods)
    EditText etSvymethods;
    @BindView(R.id.et_collectedsamplecount)
    EditText etCollectedsamplecount;
    @BindView(R.id.tv_isvocaniccone)
    TextView tvIsvocaniccone;
    @BindView(R.id.tv_islava)
    TextView tvIslava;
    @BindView(R.id.tv_iscrater)
    TextView tvIscrater;
    @BindView(R.id.et_photoAiid)
    EditText etPhotoAiid;
    @BindView(R.id.et_photodescArwid)
    EditText etPhotodescArwid;
    @BindView(R.id.et_photographer)
    EditText etPhotographer;
    @BindView(R.id.et_remark)
    EditText etRemark;
    @BindView(R.id.et_projectid)
    EditText etProjectid;
    @BindView(R.id.et_samplecount)
    EditText etSamplecount;
    @BindView(R.id.et_datingsamplecount)
    EditText etDatingsamplecount;
    @BindView(R.id.tv_isinmap)
    TextView tvIsinmap;
    @BindView(R.id.ll_visibile)
    LinearLayout llVisibile;
    @BindView(R.id.btn_submit)
    Button btnSubmit;
    @BindView(R.id.tv_visibile)
    TextView tvVisibile;
    private TabTitleBuilder tabTitleBuilder;
    private PhotoRecycleBuild photoRecycleBuild;
    private Dialog myDialog;
    private String type;
    private String taskId = "";
    private String projectId = "";
    private String projectName = "";
    private String taskName = "";
    private boolean isOnline;
    private int joninType;
    private String uuid;
    private DaoSession daoSession;
    private long _id = -1;
    private String urlArr;
    Calendar calendar = Calendar.getInstance(Locale.CHINA);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_volcanicsvypoint);
        ButterKnife.bind(this);
        daoSession = BaseApplication.getInstance().getDaoSession();
        tabTitleBuilder = new TabTitleBuilder(llTabTitle, this);
        initView();
    }



    public void initView() {
        joninType = getIntent().getIntExtra("joninType", 1);
        photoRecycleBuild = new PhotoRecycleBuild(this, rvPics, joninType);
        if (joninType != 2) {
            tvTitle.setText("火山调查观测点-点");
            tvRightText.setText("保存");
            double x = getIntent().getDoubleExtra("x", 0.0);
            double y = getIntent().getDoubleExtra("y", 0.0);
            type = getIntent().getStringExtra("type");
            taskId = getIntent().getStringExtra("taskId");
            projectId = getIntent().getStringExtra("projectId");
            projectName = getIntent().getStringExtra("projectName");
            taskName = getIntent().getStringExtra("taskName");
            isOnline = getIntent().getBooleanExtra("isOnLine", true);
            if (TextUtils.isEmpty(type)) {
                finish();
            }
            if (isOnline && TextUtils.isEmpty(taskId)){
                finish();
            }
            if (isOnline && TextUtils.isEmpty(projectId)){
                finish();
            }
            tabTitleBuilder.setLat(x);
            tabTitleBuilder.setLon(y);
            if (getIntent().hasExtra("_id")) {
                _id = getIntent().getLongExtra("_id", -1);
                setLocalData(_id);
            }
            if (1 == Constant.IS_ON_LINE){
                btnSubmit.setVisibility(View.VISIBLE);
            }else {
                btnSubmit.setVisibility(View.GONE);
            }
        } else {
            isOnline = getIntent().getBooleanExtra("isOnLine", false);
            if (1 == Constant.IS_ON_LINE){
                tvTitle.setText("火山调查观测点-点详情");
                uuid = getIntent().getStringExtra("uuid");
                tabTitleBuilder.setEnabled();
                setEnableFalse();
                getDetailHttp();
                btnSubmit.setVisibility(View.GONE);
            }else {
                tvTitle.setText("火山调查观测点-点");
                tvRightText.setText("保存");
                uuid = getIntent().getStringExtra("uuid");
                if (getIntent().hasExtra("_id")) {
                    _id = getIntent().getLongExtra("_id", -1);
                    setLocalData(_id);
                }
                btnSubmit.setVisibility(View.GONE);
            }
        }
    }

    public void setLocalData(long a) {
        if (a == -1) {
            return;
        }
        List<VolcanicSvyPointDbEntity> students = daoSession.loadAll(VolcanicSvyPointDbEntity.class);
        for (VolcanicSvyPointDbEntity volcanicSvyPointDbEntity : students) {
            if (a == volcanicSvyPointDbEntity.get_id()) {
                setDetail(volcanicSvyPointDbEntity);
            }
        }
    }

    private void setEnableFalse() {
        etId.setEnabled(false);
        etFieldid.setEnabled(false);
        etLocationname.setEnabled(false);
        etSvydate.setEnabled(false);
        etPurpose.setEnabled(false);
        etSpcommentInfo.setEnabled(false);
        etElevation.setEnabled(false);
        etSvymethods.setEnabled(false);
        etCollectedsamplecount.setEnabled(false);
        tvIsvocaniccone.setEnabled(false);
        tvIslava.setEnabled(false);
        tvIscrater.setEnabled(false);
        etPhotoAiid.setEnabled(false);
        etPhotodescArwid.setEnabled(false);
        etPhotographer.setEnabled(false);
        etRemark.setEnabled(false);
        etProjectid.setEnabled(false);
        etSamplecount.setEnabled(false);
        etDatingsamplecount.setEnabled(false);
        tvIsinmap.setEnabled(false);
    }

    @OnClick({R.id.iv_back, R.id.tv_right_text, R.id.tv_visibile, R.id.tv_isvocaniccone, R.id.tv_islava
            , R.id.tv_iscrater, R.id.tv_isinmap, R.id.btn_submit,R.id.iv_id_hint,R.id.et_svydate})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_isvocaniccone:
                ShowBottomDialog.BottomDialog(this, (b, dialog) -> {
                    if (b) {
                        tvIsvocaniccone.setText("是");
                    } else {
                        tvIsvocaniccone.setText("否");
                    }
                    dialog.dismiss();
                });
                break;
            case R.id.tv_islava:
                ShowBottomDialog.BottomDialog(this, (b, dialog) -> {
                    if (b) {
                        tvIslava.setText("是");
                    } else {
                        tvIslava.setText("否");
                    }
                    dialog.dismiss();
                });
                break;
            case R.id.tv_iscrater:
                ShowBottomDialog.BottomDialog(this, (b, dialog) -> {
                    if (b) {
                        tvIscrater.setText("是");
                    } else {
                        tvIscrater.setText("否");
                    }
                    dialog.dismiss();
                });
                break;
            case R.id.tv_isinmap:
                ShowBottomDialog.BottomDialog(this, (b, dialog) -> {
                    if (b) {
                        tvIsinmap.setText("是");
                    } else {
                        tvIsinmap.setText("否");
                    }
                    dialog.dismiss();
                });
                break;
            case R.id.tv_visibile:
                if (llVisibile.getVisibility() == View.VISIBLE) {
                    llVisibile.setVisibility(View.GONE);
                    tvVisibile.setText("显示更多");
                } else {
                    llVisibile.setVisibility(View.VISIBLE);
                    tvVisibile.setText("隐藏更多");
                }
                break;
            case R.id.tv_right_text:
                save();
                break;
            case R.id.btn_submit:
                submit();
                break;
            case R.id.iv_id_hint:
                HYDialogUtils.showCommonAlertDialog(this, "长度17位，前9位，行政区划代码6位+3位专题号，后8位自定义编码，字母数字均可，不足8位#补齐\n" +
                                "3位专题号，用户自己设置。一般就是100，101，102...,201,202"
                        , (dialogInterface, i) -> {
                        });
                break;
            case R.id.et_svydate:
                showDatePickerDialog(calendar);
                break;
        }
    }

    /**
     * 时间选择
     * @param calendar
     */

    @SuppressLint("ResourceType")
    public void showDatePickerDialog(Calendar calendar) {
        // 直接创建一个DatePickerDialog对话框实例，并将它显示出来
        new DatePickerDialog(this, 4, new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
                etSvydate.setText(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth);
            }

        }
                // 设置初始日期
                , calendar.get(Calendar.YEAR)
                , calendar.get(Calendar.MONTH)
                , calendar.get(Calendar.DAY_OF_MONTH)).show();
    }

    public void save() {
        VolcanicSvyPointDbEntity bean = new VolcanicSvyPointDbEntity();
        if (null == daoSession) {
            daoSession = BaseApplication.getInstance().getDaoSession();
        }
        String province = tabTitleBuilder.getProvinceStr();
        String city = tabTitleBuilder.getCityStr();
        String area = tabTitleBuilder.getAreaStr();
        String lat = tabTitleBuilder.getLatStr();
        String lon = tabTitleBuilder.getLonStr();
        String buildingAddress = tabTitleBuilder.getBuilderAdressStr();

        String id = etId.getText().toString().trim();
        String fieldid = etFieldid.getText().toString().trim();
        String locationname = etLocationname.getText().toString().trim();
        String svydate = etSvydate.getText().toString().trim();
        String purpose = etPurpose.getText().toString().trim();
        String spcommentInfo = etSpcommentInfo.getText().toString().trim();
        String elevation = etElevation.getText().toString().trim();
        String svymethods = etSvymethods.getText().toString().trim();
        String collectedsamplecount = etCollectedsamplecount.getText().toString().trim();
        String isvocaniccone = tvIsvocaniccone.getText().toString().trim();
        String islava = tvIslava.getText().toString().trim();
        String iscrater = tvIscrater.getText().toString().trim();
        String photoAiid = etPhotoAiid.getText().toString().trim();
        String photodescArwid = etPhotodescArwid.getText().toString().trim();
        String photographer = etPhotographer.getText().toString().trim();
        String remark = etRemark.getText().toString().trim();
        String projectid = etProjectid.getText().toString().trim();
        String samplecount = etSamplecount.getText().toString().trim();
        String datingsamplecount = etDatingsamplecount.getText().toString().trim();
        String isinmap = tvIsinmap.getText().toString().trim();
        if (TextUtils.isEmpty(province)) {
            Toast("请录入地区");
            return;
        }
        if (TextUtils.isEmpty(city)) {
            Toast("请录入地区");
            return;
        }
        if (TextUtils.isEmpty(area)) {
            Toast("请录入地区");
            return;
        }
        if (TextUtils.isEmpty(lon)) {
            Toast("请录入纬度");
            return;
        }
        if (TextUtils.isEmpty(lat)) {
            Toast("请录入经度");
            return;
        }
        if (TextUtils.isEmpty(buildingAddress)) {
            Toast("请录入详细地址");
            return;
        }

        if (TextUtils.isEmpty(id)) {
            Toast("请录入观测点编号");
            return;
        }
        if (id.length() != 17){
            Toast("请录入正确的观测点编号");
            return;
        }
        bean.setProvince(province);
        bean.setCity(city);
        bean.setArea(area);
        bean.setLat(lat);
        bean.setLon(lon);
        bean.setTown(buildingAddress);

        bean.setId(id);
        bean.setFieldid(fieldid);
        bean.setLocationname(locationname);
        bean.setSvydate(svydate);
        bean.setPurpose(purpose);
        bean.setSpcommentInfo(spcommentInfo);
        bean.setElevation(elevation);
        bean.setSvymethods(svymethods);
        bean.setCollectedsamplecount(collectedsamplecount);
        bean.setIsvocaniccone("是".equals(isvocaniccone) ? "1" : "0");
        bean.setIslava("是".equals(islava) ? "1" : "0");
        bean.setIscrater("是".equals(iscrater) ? "1" : "0");
        bean.setPhotoAiid(photoAiid);
        bean.setPhotodescArwid(photodescArwid);
        bean.setPhotographer(photographer);
        bean.setCommentInfo(remark);
        bean.setProjectcode(projectid);
        bean.setSamplecount(samplecount);
        bean.setDatingsamplecount(datingsamplecount);
        bean.setIsinmap("是".equals(isinmap) ? "1" : "0");
        if (Constant.IS_ON_LINE == 1) {
            bean.setProjectId(projectId);
            bean.setProjectName(projectName);
            bean.setTaskName(taskName);
            bean.setTaskId(taskId);
        }
        if (photoRecycleBuild.getSrcList().size() != 0) {
            String url = "";
            for (int i = 0; i < photoRecycleBuild.getSrcList().size(); i++) {
                if (TextUtils.isEmpty(url)) {
                    url = FileUtil.uriToFile(photoRecycleBuild.getSrcList().get(i), activity).getPath();
                } else {
                    url = url + "," + FileUtil.uriToFile(photoRecycleBuild.getSrcList().get(i), activity).getPath();
                }
            }
            bean.setExtends7(url);
        }
        if (-1 != _id) {
            bean.set_id(_id);
        }
        daoSession.insertOrReplace(bean);
        CustomToast.showToast(this, "保存成功");
        finish();
    }

    public void submit() {
        String province = tabTitleBuilder.getProvinceStr();
        String city = tabTitleBuilder.getCityStr();
        String area = tabTitleBuilder.getAreaStr();
        String lat = tabTitleBuilder.getLatStr();
        String lon = tabTitleBuilder.getLonStr();
        String buildingAddress = tabTitleBuilder.getBuilderAdressStr();

        String id = etId.getText().toString().trim();
        String fieldid = etFieldid.getText().toString().trim();
        String locationname = etLocationname.getText().toString().trim();
        String svydate = etSvydate.getText().toString().trim();
        String purpose = etPurpose.getText().toString().trim();
        String spcommentInfo = etSpcommentInfo.getText().toString().trim();
        String elevation = etElevation.getText().toString().trim();
        String svymethods = etSvymethods.getText().toString().trim();
        String collectedsamplecount = etCollectedsamplecount.getText().toString().trim();
        String isvocaniccone = tvIsvocaniccone.getText().toString().trim();
        String islava = tvIslava.getText().toString().trim();
        String iscrater = tvIscrater.getText().toString().trim();
        String photoAiid = etPhotoAiid.getText().toString().trim();
        String photodescArwid = etPhotodescArwid.getText().toString().trim();
        String photographer = etPhotographer.getText().toString().trim();
        String remark = etRemark.getText().toString().trim();
        String projectid = etProjectid.getText().toString().trim();
        String samplecount = etSamplecount.getText().toString().trim();
        String datingsamplecount = etDatingsamplecount.getText().toString().trim();
        String isinmap = tvIsinmap.getText().toString().trim();

        if (TextUtils.isEmpty(province)) {
            Toast("请录入地区");
            return;
        }
        if (TextUtils.isEmpty(city)) {
            Toast("请录入地区");
            return;
        }
        if (TextUtils.isEmpty(area)) {
            Toast("请录入地区");
            return;
        }
        if (TextUtils.isEmpty(lon)) {
            Toast("请录入纬度");
            return;
        }
        if (TextUtils.isEmpty(lat)) {
            Toast("请录入经度");
            return;
        }
        if (TextUtils.isEmpty(buildingAddress)) {
            Toast("请录入详细地址");
            return;
        }

        if (TextUtils.isEmpty(id)) {
            Toast("请录入观测点编号");
            return;
        }
        if (id.length() != 17){
            Toast("请录入正确的观测点编号");
            return;
        }

        if (myDialog == null) {
            myDialog = DialogUtils.showRefreshDialog(activity);
        } else {
            myDialog.show();
        }
        DialogUtils.showIOSDialog(activity, "提示", "", "", "", ""
                , v -> {
                    if (null != myDialog)
                        myDialog.dismiss();
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        photoRecycleBuild.submitImage(photoRecycleBuild.getSrcList(), 1, new PhotoRecycleBuild.ImageCallBack() {
                            @Override
                            public void onCallBack(String url) {
                                VolcanicSvyPointActivity.this.urlArr = url;

                                JsonBuilder jsonBuilder = new JsonBuilder(VolcanicSvyPointActivity.this);
                                jsonBuilder.put("province", province);
                                jsonBuilder.put("city", city);
                                jsonBuilder.put("area", area);
                                jsonBuilder.put("lat", lon);
                                jsonBuilder.put("lon", lat);
                                jsonBuilder.put("town", buildingAddress);
                                jsonBuilder.put("type", type);
                                jsonBuilder.put("taskId", taskId);
                                jsonBuilder.put("projectId", projectId);
                                jsonBuilder.put("projectName", projectName);
                                jsonBuilder.put("taskName", taskName);
                                jsonBuilder.put("userId", SPUtil.get("userId", ""));
                                jsonBuilder.put("id", id);
                                jsonBuilder.put("fieldid", fieldid);
                                jsonBuilder.put("locationname", locationname);
                                jsonBuilder.put("svydate", svydate);
                                jsonBuilder.put("purpose", purpose);
                                jsonBuilder.put("spcommentInfo", spcommentInfo);
                                jsonBuilder.put("elevation", elevation);
                                jsonBuilder.put("svymethods", svymethods);
                                jsonBuilder.put("collectedsamplecount", collectedsamplecount);
                                jsonBuilder.put("isvocaniccone", "是".equals(isvocaniccone) ? 1 : 0);
                                jsonBuilder.put("islava", "是".equals(islava) ? 1 : 0);
                                jsonBuilder.put("iscrater", "是".equals(iscrater) ? 1 : 0);
                                jsonBuilder.put("photoAiid", photoAiid);
                                jsonBuilder.put("photodescArwid", photodescArwid);
                                jsonBuilder.put("photographer", photographer);
                                jsonBuilder.put("commentInfo", remark);
                                jsonBuilder.put("projectcode", projectid);
                                jsonBuilder.put("samplecount", samplecount);
                                jsonBuilder.put("datingsamplecount", datingsamplecount);
                                jsonBuilder.put("isinmap", "是".equals(isinmap) ? 1 : 0);
                                jsonBuilder.put("extends7", urlArr);
                                jsonBuilder.put("createUser", SPUtil.get("userId", ""));
                                MyHttpClient
                                        .newBuilder()
                                        .post()
                                        .url(Api.HDD_VOLCANICS_POINTS)
                                        .addParam(jsonBuilder.toJsonString())
                                        .build()
                                        .enqueue(new BaseCallBack<LoginBean>() {
                                            @Override
                                            public void onSuccess(LoginBean bean) {
                                                super.onSuccess(bean);
                                                if (bean.getCode() == 200) {
                                                    if (-1 != _id && null != volcanicSvyPointDbEntity) {
                                                        try {
                                                            daoSession.delete(volcanicSvyPointDbEntity);
                                                        } catch (Exception e) {
                                                            e.printStackTrace();
                                                        }
                                                    }
                                                    CustomToast.showToast(VolcanicSvyPointActivity.this, "提交成功");
                                                    finish();
                                                }
                                                if (myDialog != null)
                                                    myDialog.dismiss();
                                            }

                                            @Override
                                            public void onFailure(Call call, IOException e) {
                                                super.onFailure(call, e);
                                                if (myDialog != null)
                                                    myDialog.dismiss();
                                                CustomToast.showToast(VolcanicSvyPointActivity.this, "网络异常");
                                            }

                                            @Override
                                            public void onError(int code) {
                                                super.onError(code);
                                                if (myDialog != null)
                                                    myDialog.dismiss();
                                                CustomToast.showToast(VolcanicSvyPointActivity.this, "网络异常");
                                            }
                                        });
                            }
                        });
                    }
                }, "提交后不能再修改");
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != RESULT_OK) {
            return;
        }
        switch (requestCode) {
            case HYImageUtils.REQUEST_CODE_FROM_CAMERA:
                List<Uri> list_1 = new ArrayList<>();
                list_1.add(HYImageUtils.imageUriFromCamera);
                photoRecycleBuild.updataAdapter(list_1);
                break;
            case HYImageUtils.REQUEST_CODE_FROM_ALBUM:
                ArrayList<String> files = data.getStringArrayListExtra("files");
                if (files == null || files.size() == 0) {
                    return;
                }
                List<Uri> list_2 = new ArrayList<>();
                for (String file : files) {
                    list_2.add(Uri.fromFile(new File(file)));
                }
                photoRecycleBuild.updataAdapter(list_2);
                // submitImage(list_2, correctTypeListEntity.getFieldList().get(lastClickItemPosition));
                break;
        }
    }

    public void getDetailHttp() {
        if (myDialog == null) {
            myDialog = DialogUtils.showRefreshDialog(activity);
        } else {
            myDialog.show();
        }
        String url = Api.HDD_VOLCANICS_POINTS + "/" + uuid;
        MyHttpClient
                .newBuilder()
                .get()
                .url(url)
                .build()
                .enqueue(new BaseCallBack<VolcanicSvyPointEntity>() {
                    @Override
                    public void onSuccess(VolcanicSvyPointEntity bean) {
                        super.onSuccess(bean);
                        if (bean.getCode() == 200) {
                            setDetailData(bean.getData());
                        }
                        if (myDialog != null)
                            myDialog.dismiss();
                    }

                    @Override
                    public void onFailure(Call call, IOException e) {
                        super.onFailure(call, e);
                        if (myDialog != null)
                            myDialog.dismiss();
                        CustomToast.showToast(VolcanicSvyPointActivity.this, "网络异常");
                    }

                    @Override
                    public void onError(int code) {
                        super.onError(code);
                        if (myDialog != null)
                            myDialog.dismiss();
                        CustomToast.showToast(VolcanicSvyPointActivity.this, "网络异常");
                    }
                });
    }

    private VolcanicSvyPointDbEntity volcanicSvyPointDbEntity;

    private void setDetail(VolcanicSvyPointDbEntity bean) {
        this.volcanicSvyPointDbEntity = bean;
        tabTitleBuilder.setDetailText(bean.getProvince(), bean.getCity()
                , bean.getArea(),bean.getLat(),bean.getLon(), bean.getTown());

        etId.setText(StringUtil.isNull(bean.getId()));
        etFieldid.setText(StringUtil.isNull(bean.getFieldid()));
        etLocationname.setText(StringUtil.isNull(bean.getLocationname()));
        etSvydate.setText(StringUtil.isNull(bean.getSvydate()));
        etPurpose.setText(StringUtil.isNull(bean.getPurpose()));
        etSpcommentInfo.setText(StringUtil.isNull(bean.getSpcommentInfo()));
        etElevation.setText(StringUtil.isNull(bean.getElevation()));
        etSvymethods.setText(StringUtil.isNull(bean.getSvymethods()));
        etCollectedsamplecount.setText(StringUtil.isNull(bean.getCollectedsamplecount()));
        tvIsvocaniccone.setText("1".equals(bean.getIsvocaniccone()) ? "是" : "否");
        tvIslava.setText("1".equals(bean.getIslava()) ? "是" : "否");
        tvIscrater.setText("1".equals(bean.getIscrater()) ? "是" : "否");
        etPhotoAiid.setText(StringUtil.isNull(bean.getPhotoAiid()));
        etPhotodescArwid.setText(StringUtil.isNull(bean.getPhotodescArwid()));
        etPhotographer.setText(StringUtil.isNull(bean.getPhotographer()));
        etRemark.setText(StringUtil.isNull(bean.getCommentInfo()));
        etProjectid.setText(StringUtil.isNull(bean.getProjectcode()));
        etSamplecount.setText(StringUtil.isNull(bean.getSamplecount()));
        etDatingsamplecount.setText(StringUtil.isNull(bean.getDatingsamplecount()));
        tvIsinmap.setText("1".equals(bean.getIsinmap()) ? "是" : "否");
        if (!TextUtils.isEmpty(bean.getExtends7())) {
            String[] arr = bean.getExtends7().split(",");
            List<Uri> list = new ArrayList<>();
            for (int i = 0; i < arr.length; i++) {
                File file = new File(arr[i]);
                Uri uri = Uri.fromFile(file);
                list.add(uri);
            }
            photoRecycleBuild.updataAdapter(list);
        }
    }

    private void setDetailData(VolcanicSvyPointDbEntity bean) {
        this.volcanicSvyPointDbEntity = bean;
        tabTitleBuilder.setDetailText(bean.getProvince(), bean.getCity()
                , bean.getArea(),bean.getLat(),bean.getLon(), bean.getTown());

        etId.setText(StringUtil.isNull(bean.getId()));
        etFieldid.setText(StringUtil.isNull(bean.getFieldid()));
        etLocationname.setText(StringUtil.isNull(bean.getLocationname()));
        etSvydate.setText(StringUtil.isNull(bean.getSvydate()));
        etPurpose.setText(StringUtil.isNull(bean.getPurpose()));
        etSpcommentInfo.setText(StringUtil.isNull(bean.getSpcommentInfo()));
        etElevation.setText(StringUtil.isNull(bean.getElevation()));
        etSvymethods.setText(StringUtil.isNull(bean.getSvymethods()));
        etCollectedsamplecount.setText(StringUtil.isNull(bean.getCollectedsamplecount()));
        tvIsvocaniccone.setText("1".equals(bean.getIsvocaniccone()) ? "是" : "否");
        tvIslava.setText("1".equals(bean.getIslava()) ? "是" : "否");
        tvIscrater.setText("1".equals(bean.getIscrater()) ? "是" : "否");
        etPhotoAiid.setText(StringUtil.isNull(bean.getPhotoAiid()));
        etPhotodescArwid.setText(StringUtil.isNull(bean.getPhotodescArwid()));
        etPhotographer.setText(StringUtil.isNull(bean.getPhotographer()));
        etRemark.setText(StringUtil.isNull(bean.getCommentInfo()));
        etProjectid.setText(StringUtil.isNull(bean.getProjectcode()));
        etSamplecount.setText(StringUtil.isNull(bean.getSamplecount()));
        etDatingsamplecount.setText(StringUtil.isNull(bean.getDatingsamplecount()));
        tvIsinmap.setText("1".equals(bean.getIsinmap()) ? "是" : "否");
        photoRecycleBuild.setHttpUrl(bean.getExtends7());
    }
}
